{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
\paperw12240\paperh15840\margl1440\margr1440\vieww13980\viewh11120\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0\b\fs28 \cf0 Create Your First Legacy C/C++ Test Project with CppUTest
\b0\fs24 \
\
This paper describes how to integrate CppUTest based off-target testing with your production code using the GCC toolchain environment.\
\

\b 1) Install gcc toolchain \

\b0 In Ubuntu\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1 \cf0 	sudo apt-get install build-essential\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 \
In windows, I find cygwin ({\field{\*\fldinst{HYPERLINK "http://www.cygwin.com/"}}{\fldrslt http://www.cygwin.com/}}) is the least trouble,  The install may take a couple hours.  Make sure to select the \'91Devel\'92 package in the installer.\
\

\b 2) Download, Install and build CppUTest\

\b0 Download the latest from cpputest.org.  It is best to put it into a directory near your production code so it can be checked into your source repository.\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1 \cf0 NOTE: My starter kit is not compatible with the install method described on cpputest.org. You cannot \'91apt-get install cpputest\'92 for use with my starter kit.  Please install it as follows:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1 \cf0 	cd /close-to-your-production-code/tools/cpputest\
	./configure\
	make check\
	make tdd\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 You should see CppUTest\'92s tests run.  If you get errors, they are often easy to fix by looking at the error message.  Often it is a matter of disabling some warning.  You can also check with me or the cpputest google group.  Please let me know there is a need for a change these directions.  \
\

\b 3) Define CPPUTEST_HOME\

\b0 Point  CPPUTEST_HOME to the root directory of CppUTest.  If you don't, the starter project makefile will not be able to find MakefileWorker.mk and the needed include files.\

\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1\b0 \cf0 	export CPPUTEST_HOME=/close-to-your-production-code/tools/cpputest\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 Under cygwin, you can use a windows environment variable.\

\b \
4) Move the starter project\

\b0 Move the starter project folder so that it is in the source repository with your production code. You want to be able to conveniently access your production code files and dependencies using relative paths.  For example 
\f1 /close-to-your-production-code/cpputest-starter-project.
\f0 \

\b \
5) Build the starter project\

\b0 From a terminal window, change the directory to the root of the starter project. The same directory where this file was found. The make all.\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1 \cf0 	cd /close-to-your-production-code/cpputest-starter-project\
	make all\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 \
You should see output announcing each file compiling and finally running the tests like this:\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f1 \cf0 compiling blah.cpp\
//one line for each file compiled\
Building archive lib/libexample.a\
//etc\
Linking example_tests\
Running example_tests\
..............\
OK (14 tests, 14 ran, 47 checks, 0 ignored, 0 filtered out, 0 ms)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0 \cf0 \
\

\b 6) You are ready to add your first test.  Now go look at this page:\
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\pardirnatural

\b0 \cf0 	\'95	{\field{\*\fldinst{HYPERLINK "https://wingman-sw.com/articles/get-your-legacy-c-into-a-test-harness"}}{\fldrslt https://wingman-sw.com/articles/get-your-legacy-c-into-a-test-harness}}
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\cf0 \
Keep working in small verifiable steps.\

\b0 \
\
}